#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
//#define addr(l , r) (((l) + (r)) | ((l) != (r)))

using namespace std;

int n;
int l[1000], r[1000];

struct interval
{
	int pos, type;
} data[2000];
int dp;

int main ()
{
	char buf[50];

	int ct = 0;

	while (scanf("%d", &n) > 0 && n > 0)
	{
//		account = 0;
		for (int i = 0; i < n; i ++)
		{
			int a, b, c, d;

/*			scanf("%s", buf);

			a = (buf[0] - '0') * 10 + (buf[1] - '0');
			b = (buf[3] - '0') * 10 + (buf[4] - '0');
			c = (buf[6] - '0') * 10 + (buf[7] - '0');
			d = (buf[9] - '0') * 10 + (buf[10] - '0');*/

			a = rand() % 24;
			b = rand() % 60;
			c = rand() % 24;
			d = rand() % 60;

			a %= 24;
			c %= 24;
			l[i] = a * 60 + b;
			r[i] = c * 60 + d;

//			printf("%d %d\n", l[i], r[i]);
		}

		for (int i = 0; i < n; i ++)
		{
			dp = 0;
			int cur = 0;
			for (int j = 0; j < n; j ++)
				if (intersect(i, j))
				{
					data[dp].pos = l[j];
					data[dp].type = 1;
					dp ++;
					data[dp].pos = r[j];
					data[dp].type = 1;
					dp ++;

					if (l[j] > r[j])
						cur ++;
				}
			
		}
		
		printf("Case %d: %d\n", ++ ct, ans);
	}

	return 0;
}